import { request } from "../../utils/request.js";
import regeneratorRuntime from "../../utils/runtime.js";
Page({
  data: {
    userinfo:{},
    createlist:[]
  },
  async getUserinfo(uid){
    const result=await request({url: 'http://musicapi.leanapp.cn/user/detail?uid='+uid});
    let {eventCount,follows,followeds,nickname,signature,gender,avatarUrl,backgroundUrl}=result.profile
    let userinfo={eventCount,follows,followeds,nickname,signature,gender,avatarUrl,backgroundUrl}
    this.setData({
      userinfo
    })
  },
  async getUserPlaylist(uid){
    const result=await request({url:'http://musicapi.leanapp.cn/user/playlist?uid='+uid});           
    const createlist=result.playlist.map(v=>{
        return {
          name:v.name,
          id:v.id,
          coverImgUrl:v.coverImgUrl,
          trackCount:v.trackCount,
          playCount:v.playCount
        }
    });
    this.setData({
        createlist
    })
  },
  onLoad: function (options) {
    let uid=options.uid
    this.getUserinfo(uid);
    this.getUserPlaylist(uid);
  },
})